package com.deng.performance.first.view
{
	import com.deng.performance.first.vo.OrganizationFirstBonusVo;
	
	import flash.events.FocusEvent;
	
	import mx.controls.Alert;
	import mx.controls.TextInput;
	import mx.events.FlexEvent;
	import mx.resources.ResourceManager;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	
	public class OrganizationBonusUpdateTI  extends TextInput
	{
		private var selVo:OrganizationFirstBonusVo;
		public function OrganizationBonusUpdateTI()
		{
			
			this.addEventListener(FlexEvent.CREATION_COMPLETE,showHandler);
			this.addEventListener(FocusEvent.FOCUS_OUT,upEvt);
			this.addEventListener(FlexEvent.SHOW,showHandler);
			super();
			this.restrict = "-0-9.";
			this.setStyle("backgroundColor","#FFFFFF");
			this.setStyle("cornerRadius","2");
			this.setStyle("borderThickness","1");
			this.setStyle("borderStyle","solid");
			this.setStyle("borderColor","#C0C0BE");
			this.setStyle("fontSize","12");
			this.setStyle("fontFamily","Times New Roman");
			this.setStyle("color","#000000");
		}
		
		private function upEvt(event:FocusEvent):void{
			try
			{
				selVo.put_value = new Number(this.text).toString();
				
			}
			catch(err:Error)
			{
				
			}
			(this.data as OrganizationFirstBonusVo).put_value = selVo.put_value;
			
//			if(event.keyCode == 13)
//			{
//				var ro:RemoteObject = new RemoteObject();
//				ro.destination = "EmployeeImpl";			
//				ro.addEventListener(FaultEvent.FAULT,flt);
//				ro.addEventListener(ResultEvent.RESULT,updateRst);
//			}
			
		}
//		private function updateRst(evt:ResultEvent):void{
//			Alert.show(ResourceManager.getInstance().getString("lang", "update_success"));
////			var rtEvt:ReturnEvent=new ReturnEvent(ReturnEvent.loadDispenseManagerList);
////			rtEvt.dispatch();
//		}
//		private function flt(evt:FaultEvent):void{
//			Alert.show(evt.fault.getStackTrace());
//		}
		private function showHandler(evt:FlexEvent):void{
			selVo = this.data as OrganizationFirstBonusVo;
			this.text = selVo.put_value;
		}

	}
}